package edu.tyut.game.ui.learn

import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import edu.tyut.game.databinding.ActivityPoemBinding
import edu.tyut.game.logic.model.PoemPoet
import edu.tyut.game.utils.LogUtils
import edu.tyut.game.utils.StatusBarUtils

class PoemActivity : AppCompatActivity() {

    private val tag = this::class.java.name

    private lateinit var binding: ActivityPoemBinding



    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // 埋点观察
        binding = ActivityPoemBinding.inflate(layoutInflater)
        setContentView(binding.root)
        // 隐藏ActionBar
        // 状态栏透明
        StatusBarUtils.setTranslucentStatusBar(this)

        val poemPoet = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            intent.getSerializableExtra("poemPoet", PoemPoet::class.java)
        } else {
            intent.getSerializableExtra("poemPoet")
        } as PoemPoet

        LogUtils.d(tag, poemPoet.toString())

        binding.title.text = poemPoet.title
        binding.poet.text = "【${poemPoet.dynasty}】${poemPoet.poetName}"
        binding.content.text = poemPoet.content
    }

    companion object{
        fun actionStart(context: Context, poemPoet: PoemPoet){
            val intent = Intent(context, PoemActivity::class.java)
            intent.putExtra("poemPoet", poemPoet)
            context.startActivity(intent)
        }
    }
}